---
title: BamlValidationError
description: Technical reference for the BamlValidationError class
---

The `BamlValidationError` class represents an error that occurs when BAML fails to parse or validate LLM output.

## Type Definition

<CodeBlocks>
```typescript Type Definition
class BamlValidationError extends Error {
  type: 'BamlValidationError'
  message: string
  prompt: string
  raw_output: string
  detailed_message: string
}
```
</CodeBlocks>

## Properties

<ParamField
  path="type"
  type="'BamlValidationError'"
>
  Literal type identifier for the error class.
</ParamField>

<ParamField
  path="message"
  type="string"
>
  Error message describing the specific validation failure.
</ParamField>

<ParamField
  path="prompt"
  type="string"
>
  The original prompt sent to the LLM.
</ParamField>

<ParamField
  path="raw_output"
  type="string"
>
  The raw output from the LLM that failed validation.
</ParamField>

<ParamField
  path="detailed_message"
  type="string"
>
  Comprehensive error information that includes the complete history of all failed attempts when using fallback clients or retry policies. When multiple attempts are made (via fallback or retry), this field contains formatted details about each failed attempt, making it invaluable for debugging complex client configurations.
</ParamField>

## Type Guards

The error can be identified using TypeScript's `instanceof` operator:

<CodeBlocks>
```typescript Type Check
if (error instanceof BamlValidationError) {
  // Handle validation error
}
```
</CodeBlocks>

## Related Errors

- [BamlClientFinishReasonError](/ref/baml_client/errors/baml-client-finish-reason-error)
- [BamlClientError](/ref/baml_client/errors/baml-client-finish-reason-error)
